﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Linkmeme.Views.Source
{
    public partial class Index : ViewPage   //<SourceViewData<SourceBase>>
    {
        protected string sourceType = "...";
        protected string providerName = "";

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SourceViewData<Picture> svdPic = this.ViewData["data"] as SourceViewData<Picture>;
            if (svdPic != null)
            {
                contentlist.InnerHtml = Html.RenderUserControl("~/Views/Shared/PhotoList.ascx", svdPic.Items, new { ItemCount = 4 });
                sourceType = svdPic.SourceType.ToCH();
                providerName = svdPic.ProviderName;
                return;
            }

            SourceViewData<Blog> svdBlog = this.ViewData["data"] as SourceViewData<Blog>;
            if (svdBlog != null)
            {
                contentlist.InnerHtml = Html.RenderUserControl("~/Views/Shared/BlogList.ascx", svdBlog.Items, new { ItemCount = 4 });
                sourceType = svdBlog.SourceType.ToCH();
                providerName = svdBlog.ProviderName;
                return;
            }

            SourceViewData<Bookmark> svdBookmark = this.ViewData["data"] as SourceViewData<Bookmark>;
            if (svdBookmark != null)
            {
                contentlist.InnerHtml = Html.RenderUserControl("~/Views/Shared/BookmarkList.ascx", svdBookmark.Items, new { ItemCount = 4 });
                sourceType = svdBookmark.SourceType.ToCH();
                providerName = svdBookmark.ProviderName;
                return;
            }

            SourceViewData<Status> svdStatus = this.ViewData["data"] as SourceViewData<Status>;
            if (svdStatus != null)
            {
                contentlist.InnerHtml = Html.RenderUserControl("~/Views/Shared/StatusList.ascx", svdStatus.Items, new { ItemCount = 4 });
                sourceType = svdStatus.SourceType.ToCH();
                providerName = svdStatus.ProviderName;
                return;
            }

        }
    }
}
